package LiKou;

import java.util.List;
import java.util.Stack;

public class MinStack {
    private Stack<Integer> reality;
    private Stack<Integer> min;
    public MinStack() {
        reality=new Stack<>();
        min=new Stack<>();
    }

    public void push(int x) {
        if(min.size()==0 || min.peek()>=x){
            min.push(x);
        }else{
            min.push(min.peek());
        }
        reality.push(x);
    }

    public void pop() {
        min.pop();
        reality.pop();
    }

    public int top() {
        return reality.peek();
    }

    public int getMin() {
        return min.peek();
    }
}
